/*
 * EvolutiveCaseGenerator.h
 *
 *  Created on: 29/05/2011
 *      Author: godinho
 */

#ifndef EVOLUTIVECASEGENERATOR_H_
#define EVOLUTIVECASEGENERATOR_H_

#include "CaseGenerator.h"
#include <evolutive/FitnessFunction.h>
#include <evolutive/LifeSimulator.h>
#include <evolutive/CaseSelector.h>
#include <evolutive/OffspringGenerator.h>
#include <controller/CaseRecycler.h>
#include <localview/LocalView.h>
#include <evolutive/EventListener.h>

class EvolutiveCaseGenerator: public CaseGenerator {
public:
	EvolutiveCaseGenerator();
	virtual ~EvolutiveCaseGenerator();

	virtual void startEvolution(std::vector<Case*> cases);

	virtual std::vector<Case*> getCases();

	void setFitnessFunction(FitnessFunction* fitnessFunction);

	void setLifeSimulator(LifeSimulator* lifeSimulator);

	void setCaseSelector(CaseSelector* selector);

	void setOffspringGenerator(OffspringGenerator* offspringGenerator);

	FitnessFunction* getFitnessFunction();

	LifeSimulator* getLifeSimulator();

	CaseSelector* getCaseSelector();

	OffspringGenerator* getOffspringGenerator();

	bool timedOut();

	void killGeneration(std::vector<Case*> cases);

	void setEventListener(EventListener* listener);

	void setTimedOut();

private:
	EventListener* mListener;
	FitnessFunction* mFitnessFunction;
	LifeSimulator* mLifeSimulator;
	CaseSelector* mCaseSelector;
	OffspringGenerator* mOffspringGenerator;
	CaseRecycler* mRecycler;
	LocalView* mNetwork; //TODO get it
	std::vector<Case*> mParents;
	std::vector<Case*> mChildren;
	bool mEndIterations;
};

#endif /* EVOLUTIVECASEGENERATOR_H_ */
